import { request as httpRequest } from '@/utils/request';

const request = httpRequest.getAxios();

export interface EbookEntity {
  id?: number;
  title?: string;
  description?: string;
  coverImage?: string;
  fileName?: string;
  category?: string;
}

// Get ebook by id
export function getEbook(id: number) {
  return request({
    url: `/api/ebook/${id}`,
    method: 'get',
  });
}

// Add new ebook
export function addEbook(data: EbookEntity) {
  return request({
    url: '/api/ebook',
    method: 'post',
    data,
  });
}

// Update ebook
export function updateEbook(data: EbookEntity) {
  return request({
    url: '/api/ebook',
    method: 'put',
    data,
  });
}

// Delete ebook
export function deleteEbook(id: number) {
  return request({
    url: `/api/ebook/${id}`,
    method: 'delete',
  });
}

// Get ebook list with pagination
export function getEbookList(data: EbookEntity & PageData) {
  return request({
    url: '/api/ebook/list',
    method: 'post',
    data,
  });
}
